package com.KKd.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @author 14587
 * @date 2020/11/7 16:21
 */
@Controller
@RequestMapping("/user")
public class LoginController {
    @RequestMapping("/login")
    public String login(HttpSession session,String username, String password){
        //需要把用户信息保存到session中，以保证用session的时候用户在里面
        session.setAttribute("userInfo",username);
        return "main";
    }

    @RequestMapping("/goLogin")
    public String goLogin(){
        return "login";
    }

    @RequestMapping("/goMain")
    public String goMain(HttpSession session){
        return "main";
    }

    @RequestMapping("/goOut")
    public String goOut(HttpSession session){
        session.removeAttribute("userInfo");
        return "main";
    }
}
